package bankapplication.com.acme.bankapp.domain.bank;

import java.io.Serializable;
import java.util.ArrayList;

public class Client implements Serializable{
  private ArrayList<Account> accounts;
  private Gender gender;
  private String name;
  public Client(String name, Gender gender, ArrayList<Account> accounts) throws IllegalArgumentException {
    this.name = name;
    this.gender = gender;
    this.accounts = accounts;
  }
  public ArrayList<Account> getAcconts(){
    return accounts;
  }
  public void getClientSaltation(){
    System.out.println(gender.greeting + " " + name);
  }
  public String getName(){
    return name;
  }
  public Gender getGender(){
    return gender;
  }
  public void addAccount(Account account){
    
    accounts.add(account);
  }
  
  
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((accounts == null) ? 0 : accounts.hashCode());
    result = prime * result + ((gender == null) ? 0 : gender.hashCode());
    result = prime * result + ((name == null) ? 0 : name.hashCode());
    return result;
  }
  @Override
  public boolean equals(Object obj){
    if(obj == null){
      return false;
    }
    if(getClass() != obj.getClass()){
      return false;
    }
    Client other = (Client)obj;
    if(!other.getName().equals(name) || other.gender != gender){
      return false;
    }
    return true;
  }
  
  @Override
  public String toString() {
    StringBuffer sb = new StringBuffer();
    sb.append("Client [accounts=" + accounts + ", gender=" + gender + ", name="
        + name + "]");
    return sb.toString();
  }
  
}
